package com.prs.crm.dao.doc.impl;

import java.util.Collection;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.doc.DocumentTaskTypeDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.doc.DocumentTaskType;
import com.prs.crm.domain.hr.Dept;

public class DocumentTaskTypeDaoImpl extends BaseDaoImpl<DocumentTaskType>implements DocumentTaskTypeDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<DocumentTaskType> getAllDocumentTaskType() {
		return (List<DocumentTaskType>)this.getHibernateTemplate().execute(
				new HibernateCallback()
				{
					public Object doInHibernate(Session session) throws HibernateException {
				Criteria criteria = session.createCriteria(DocumentTaskType.class);
				return criteria.list();
			  }
				}
		);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Collection<DocumentTaskType> getAllDocumentTaskTypes() {
		return (Collection<DocumentTaskType>)this.getHibernateTemplate().execute(
				new HibernateCallback()
				{
					public Object doInHibernate(Session session) throws HibernateException {
			        	Criteria criteria = session.createCriteria(DocumentTaskType.class);
			        	criteria.addOrder(Order.asc("id"));
			        	return criteria.list();
			        }   
				}
		);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Collection<DocumentTaskType> getRootDocumentTaskType() {
		return (Collection<DocumentTaskType>)this.getHibernateTemplate().execute(
				new HibernateCallback()
				{
					public Object doInHibernate(Session session) throws HibernateException {
			        	Criteria criteria = session.createCriteria(DocumentTaskType.class);
			        	criteria.addOrder(Order.asc("id"));
			        	return criteria.list();
			        }   
				}
		);
	}



}
